home *** CD-ROM | disk | FTP | other *** search
/ Winzipper / Winzipper_ISO.iso / cad / drafix quickcad / PRO400 / MACROS / LIST.D < prev    next >
Encoding:
Text File  |  1995-01-24  |  5.4 KB  |  217 lines

  1. // list.d
  2. //
  3. // generate a symbol list and number each symbol
  4. //
  5. // Copyright (c) David G. Shipman 7/94
  6. // 
  7.  
  8. BOOL    bType,
  9.     bDesc;
  10.  
  11. HANDLE    hSel,
  12.     hEnt,
  13.     hSymList;
  14.  
  15. STRING    sDQLExpression,
  16.     sLayer,
  17.     sSymbolDesc,
  18.     sSymbolType,
  19.     sSymbol;
  20.  
  21. NUMBER    nCount,
  22.     nSymCount,
  23.     nTextHeight,
  24.     nDrawingScale,
  25.     nSize,
  26.     nHorizJust,
  27.     nVertJust,
  28.     nLeft,
  29.     nTop,
  30.     nRight,
  31.     nBottom,
  32.     nTAspect,
  33.     nTSize;
  34.  
  35. XY    xyMin,
  36.     xyMax,
  37.     xyExtents,
  38.     xyPt,
  39.     xyStartPt,
  40.     xyTemp,
  41.     xyStartLine,
  42.     xyEndLine;
  43.  
  44. procedure pnTableHeader()
  45. // %1 = xyStartPoint.x of table
  46. // %2 = xyStartPoint.y of table
  47. // %3 = text aspect
  48. // %4 = text size
  49. {
  50.     // assign proc vars
  51.     xyPt.x = %1;
  52.     xyPt.y = %2;
  53.     nTA = %3;
  54.     nTS = %4;
  55.  
  56.     xyPt.y = xyPt.y + (2 * nTS);
  57.     // create the top line of the title
  58.     StartPoly("polyline");
  59.         AddVertex(xyPt.x - (1 * nTA), xyPt.y - (.65 * nTS));
  60.         AddVertex(xyPt.x - (1 * nTA), xyPt.y + (1.35 * nTS));
  61.         AddVertex(xyPt.x + (93 * nTA), xyPt.y + (1.35 * nTS));
  62.         AddVertex(xyPt.x + (93 * nTA), xyPt.y - (.65 * nTS));
  63.     EndPoly();
  64.     
  65.     // add the column titles
  66.     AddEntity("text", "ITEM", xyPt);
  67.     xyPt.x = xyPt.x + nTAspect * 7;
  68.     AddEntity("text", "PART NO.", xyPt);
  69.     xyPt.x = xyPt.x + nTAspect * 18;
  70.     AddEntity("text", "QUAN.", xyPt);
  71.     xyPt.x = xyPt.x + nTAspect * 9;
  72.     AddEntity("text", "DESCRIPTION", xyPt);
  73. }
  74.  
  75. // add a new layer
  76. Table("add", "layer", "List", "Symbol List", "current", 
  77.         Table("find", "color", "red"));
  78.  
  79. // make the new layer current
  80. Execute("menu", "SetLayer", Table("find", "layer", "List"));
  81. Execute("menu", "SetColor", Table("find", "color", "red"));
  82. Execute("menu", "SetStyle", Table("find", "style", "solid"));
  83.  
  84. // get some necessary information
  85. GetData("drawingscale", &nDrawingScale);
  86. GetData("textheight", &nTextHeight);
  87. GetData("TextAspect", &nTAspect);
  88. GetUser("xy", "Pick UPPER RIGHT corner of list", &xyStartPt);
  89.  
  90. // convert sheet sizes to world sizes
  91. nSize = 1/nDrawingScale;
  92. nTAspect = nTextHeight * nTAspect * nSize;
  93. nTSize = nTextHeight * nSize;
  94.  
  95. // define starting point for list
  96. xyStartPt.x = xyStartPt.x - (93 * nTAspect);
  97. xyStartPt.y = xyStartPt.y - (nTSize * 1.40);
  98.  
  99. // procedure to build the header for the table
  100. pnTableHeader(xyStartPt.x, xyStartPt.y, nTAspect, nTSize);
  101.  
  102. // procedure TableHeader borrows this variable name
  103. // we need to reset it now
  104. xyPt = xyStartPt;
  105.  
  106. // initilize the counter
  107. nCount = 1;
  108.  
  109. // open a symbol list, helps isolate symbols
  110. hSymList = Open("symlist", "*");
  111. while(GetNextSymbol(hSymList, &sSymbol))
  112. {
  113.  
  114.     // create a DQL expression, and open a selection set
  115.     sDQLExpression = "DB SymbolName = '" + sSymbol + "'";
  116.     hSel = Open("selection", sDQLExpression);
  117.     if(!(hSel))
  118.         Exit(%abort, "UNABLE TO OPEN SELECTION SET!!");
  119.  
  120.     ResetSelection(hSel);
  121.     while(hEnt = GetNextSelection(hSel))
  122.     {
  123.         // get necessary data, check if it's valid
  124.         GetDBData(hEnt, "SymbolDesc", &sSymbolDesc);
  125.         if(StringCompare(sSymbolDesc,  ""))
  126.         {
  127.             bDesc = %false;
  128.             break;
  129.         }
  130.  
  131.         // used later to determine if a valid description is present
  132.         bDesc = %true;
  133.  
  134.         GetDBData(hEnt, "SymbolType", &sSymbolType);
  135.         if(StringCompare(sSymbolType, ""))
  136.         {
  137.             bType = %false;
  138.             break;
  139.         }
  140.  
  141.         // used later to determine if a valid type is present
  142.         bType = %true;
  143.  
  144.         // put number in circle on drawing
  145.         if((bType == %true) && (bDesc == %true))
  146.         {
  147.             // calculate symbol extents
  148.             GetExtent(hEnt, &xyMin, &xyMax);
  149.             xyExtents.x = xyMax.x - xyMin.x;
  150.             xyExtents.y = xyMax.y - xyMin.y;
  151.             xyPt.x = (xyExtents.x * .5) + xyMin.x;
  152.             xyPt.y = (xyExtents.y * .5) + xyMin.y;
  153.  
  154.             // set text justification for symbol labeler
  155.             SetData("TextHorzJust", 2);
  156.             SetData("TextVertJust", 16);
  157.  
  158.             // add the text
  159.             AddEntity("text", MakeString("scalar", nCount), xyPt);
  160.  
  161.             // add the circle
  162.             AddEntity("circle", xyPt, nTSize * 1.5);
  163.  
  164.             // number of each symbol type
  165.             nSymCount = nSymCount + 1;
  166.         }
  167.     }
  168.     // and close the selection set
  169.     Close("selection", hSel);
  170.  
  171.     // reset the justification
  172.     SetData("TextHorzJust", 1);
  173.     SetData("TextVertJust", 32);
  174.     if((bType == %true) && (bDesc == %true))
  175.     {
  176.         // draw lines from left, across the top and down the right side
  177.         // of each entry in the table
  178.         StartPoly("polyline");
  179.             AddVertex(xyStartPt.x - (1 * nTAspect), xyStartPt.y - (.65 * nTSize));
  180.             AddVertex(xyStartPt.x - (1 * nTAspect), xyStartPt.y + (1.35 * nTSize));
  181.             AddVertex(xyStartPt.x + (93 * nTAspect), xyStartPt.y + (1.35 * nTSize));
  182.             AddVertex(xyStartPt.x + (93 * nTAspect), xyStartPt.y - (.65 * nTSize));
  183.         EndPoly();
  184.  
  185.         xyPt = xyStartPt;
  186.         xyPt.x = xyPt.x + nTAspect * 1;
  187.         AddEntity("text", MakeString("scalar", nCount), xyPt);
  188.         xyPt.x = xyPt.x + nTAspect * 6;
  189.         AddEntity("text", sSymbolType, xyPt);
  190.         xyPt.x = xyPt.x + nTAspect * 19;
  191.         AddEntity("text", MakeString("scalar", nSymCount), xyPt);
  192.         xyPt.x = xyPt.x + nTAspect * 8;
  193.         AddEntity("text", sSymbolDesc, xyPt);
  194.         xyStartPt.y = xyPt.y - (2 * nTSize);
  195.  
  196.         // increment the counter
  197.         nCount = nCount + 1;
  198.  
  199.     }
  200.  
  201.     // reset the symbol type counter
  202.     nSymCount = 0;
  203. }
  204. // reset the text justification
  205. SetData("TextHorzJust", 1);
  206. SetData("TextVertJust", 32);
  207.  
  208. // calculate the position and size of the last line (bottom of the chart)
  209. xyStartLine.x = xyStartPt.x - (1 * nTAspect);
  210. xyStartLine.y = xyStartPt.y + (nTSize * 1.35);
  211. xyEndLine.x = xyStartLine.x + (94 * nTAspect);
  212. xyEndLine.y = xyStartLine.y;
  213. AddEntity("line", xyStartLine, xyEndLine);
  214.  
  215. Exit(%ok, "");
  216. // [eof] list.d
  217.